﻿<phone:PhoneApplicationPage
    x:Class="WinnerSV.Views.IncontroView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
    xmlns:Command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True" >

    <i:Interaction.Triggers>
         <i:EventTrigger EventName="BackKeyPress">
            <Command:EventToCommand Command="{Binding AnteSchedina.RemoveSelectedItemCommand, Mode=OneWay, Source={StaticResource Locator}}" />
        </i:EventTrigger>
        <i:EventTrigger EventName="Loaded">
            <Command:EventToCommand Command="{Binding AnteSchedina.AlreadyUpdateScommessaCommand, Mode=OneWay, Source={StaticResource Locator}}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>

    <!-- Progress Indicator-->
    <shell:SystemTray.ProgressIndicator>
        <shell:ProgressIndicator IsIndeterminate="True"
                                 Text=""
                                 IsVisible="{Binding AnteSchedina.IsProgressIndicatorVisible, Source={StaticResource Locator}}" />
    </shell:SystemTray.ProgressIndicator>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" 
          Background="Transparent" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{Binding LocalizedResources.ApplicationTitle, Mode=OneWay, Source={StaticResource LocalizedStrings}}" 
                       Style="{StaticResource PhoneTextNormalStyle}" 
                       Foreground="{StaticResource paletteWinnerYellowDark}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" 
              Grid.Row="1" 
              Margin="12,0,12,0" 
              DataContext="{Binding AnteSchedina.SelectedIncontro, Mode=OneTime, Source={StaticResource Locator}}" >
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <!-- Data e Team -->
            <StackPanel Grid.Row="0" >
                <TextBlock Text="{Binding Path=Data}" 
                            HorizontalAlignment="Center" />
                <Grid Margin="0,16">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>

                    <Border Grid.Column="0" 
                            BorderBrush="{StaticResource paletteWinnerYellowLight}" 
                            BorderThickness="0,0,0,1">
                        <TextBlock Grid.Column="0" 
                                    Text="{Binding Path=TeamCasa}" 
                                    FontSize="{StaticResource PhoneFontSizeMediumLarge}"
                                    TextWrapping="Wrap"
                                    HorizontalAlignment="Left"
                                    VerticalAlignment="Center" />
                    </Border>
                    <Border Grid.Column="1" 
                            BorderBrush="{StaticResource paletteWinnerYellowLight}" 
                            BorderThickness="1"
                            CornerRadius="50">
                        <TextBlock Grid.Column="1"
                                Text="VS"
                                Margin="24"
                                FontWeight="Bold" 
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center" />
                    </Border>
                    <Border Grid.Column="2" 
                            BorderBrush="{StaticResource paletteWinnerYellowLight}" 
                            BorderThickness="0,0,0,1" >
                        <TextBlock Grid.Column="2" 
                                Text="{Binding Path=TeamFCasa}"
                                FontSize="{StaticResource PhoneFontSizeMediumLarge}"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Center"
                                TextWrapping="Wrap" />
                    </Border>
                </Grid>
            </StackPanel>

            <!-- Quote -->
            <ScrollViewer Grid.Row="1" Margin="0,16">
                <StackPanel Orientation="Vertical">
                    <!-- 1 X 2 -->
                    <StackPanel Orientation="Vertical" 
                                Visibility="{Binding Q1, Converter={StaticResource StringToVisConverter}}" 
                                Margin="12">
                        <TextBlock Text="{Binding LocalizedResources.Scommessa1X2Title, Mode=OneWay, Source={StaticResource LocalizedStrings}}" 
                                   HorizontalAlignment="Center" 
                                   FontSize="{StaticResource PhoneFontSizeMedium}" />
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" >
                            <StackPanel Orientation="Vertical" >
                                <TextBlock Text="{Binding Q1}" HorizontalAlignment="Center" />
                                <Button Content="1" 
                                        MinWidth="96"
                                        MinHeight="96" >
                                        <!--Opacity="{Binding AnteSchedina.ScommessaStored, ConverterParameter=Q1, Converter={StaticResource OpacityConverter}, Source={StaticResource Locator}}">-->
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Tap">
                                            <Command:EventToCommand Command="{Binding AnteSchedina.UpdateScommessaCommand, Source={StaticResource Locator}}" 
                                                                    CommandParameterValue="Q1"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding QX}" HorizontalAlignment="Center" />
                                <Button Content="X"
                                        MinWidth="96"
                                        MinHeight="96" >
                                        <!--Opacity="{Binding AnteSchedina.ScommessaStored, ConverterParameter=QX, Converter={StaticResource OpacityConverter}, Source={StaticResource Locator}}">-->
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Tap">
                                            <Command:EventToCommand Command="{Binding AnteSchedina.UpdateScommessaCommand, Source={StaticResource Locator}}" 
                                                                    CommandParameterValue="QX"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding Q2}" HorizontalAlignment="Center" />
                                <Button Content="2"
                                        MinWidth="96"
                                        MinHeight="96" >
                                        <!--Opacity="{Binding AnteSchedina.ScommessaStored, ConverterParameter=Q2, Converter={StaticResource OpacityConverter}, Source={StaticResource Locator}}">-->
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Tap">
                                            <Command:EventToCommand Command="{Binding AnteSchedina.UpdateScommessaCommand, Source={StaticResource Locator}}" 
                                                                    CommandParameterValue="Q2"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>

                    <!-- Handicap -->
                    <StackPanel Orientation="Vertical" 
                                Visibility="{Binding HC, Converter={StaticResource StringToVisConverter}}" 
                                Margin="12">
                        <TextBlock HorizontalAlignment="Center"
                                   FontSize="{StaticResource PhoneFontSizeMedium}" >
                                <Run Text="{Binding LocalizedResources.ScommessaHandicapTitle, Source={StaticResource LocalizedStrings}}" />
                                <Run Text=": " />
                                <Run Text="{Binding HC}" />
                        </TextBlock>
                        <StackPanel Orientation="Horizontal" 
                                    HorizontalAlignment="Center" >
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding Path=HC1}" HorizontalAlignment="Center" />
                                <Button Content="1" 
                                        MinWidth="96"
                                        MinHeight="96" >
                                        <!--Opacity="{Binding AnteSchedina.ScommessaStored, ConverterParameter=HC1, Converter={StaticResource OpacityConverter}, Source={StaticResource Locator}}">-->
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Tap">
                                            <Command:EventToCommand Command="{Binding AnteSchedina.UpdateScommessaCommand, Source={StaticResource Locator}}" 
                                                                    CommandParameterValue="HC1"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding Path=HCX}" HorizontalAlignment="Center" />
                                <Button Content="X"
                                        MinWidth="96"
                                        MinHeight="96" >
                                        <!--Opacity="{Binding AnteSchedina.ScommessaStored, ConverterParameter=HCX, Converter={StaticResource OpacityConverter}, Source={StaticResource Locator}}">-->
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Tap">
                                            <Command:EventToCommand Command="{Binding AnteSchedina.UpdateScommessaCommand, Source={StaticResource Locator}}" 
                                                                    CommandParameterValue="HCX"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding Path=HC2}" HorizontalAlignment="Center" />
                                <Button Content="2" 
                                        MinWidth="96"
                                        MinHeight="96" >
                                        <!--Opacity="{Binding AnteSchedina.ScommessaStored, ConverterParameter=HC2, Converter={StaticResource OpacityConverter}, Source={StaticResource Locator}}">-->
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Tap">
                                            <Command:EventToCommand Command="{Binding AnteSchedina.UpdateScommessaCommand, Source={StaticResource Locator}}" 
                                                                    CommandParameterValue="HC2"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>

                    <!-- Over/Under -->
                    <StackPanel Orientation="Vertical" 
                                Visibility="{Binding TotalScore, Converter={StaticResource StringToVisConverter}}" 
                                Margin="12" >
                        <TextBlock HorizontalAlignment="Center"
                                   FontSize="{StaticResource PhoneFontSizeMedium}" >
                                <Run Text="{Binding LocalizedResources.ScommessaOverUnderTitle, Source={StaticResource LocalizedStrings}}" />
                                <Run Text=": " />
                                <Run Text="{Binding TotalScore}" />
                        </TextBlock>
                        <StackPanel Orientation="Horizontal" 
                                    HorizontalAlignment="Center" >
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding Path=OVER}" HorizontalAlignment="Center" />
                                <Button Content="Over" 
                                        MinWidth="96" 
                                        MinHeight="96" >
                                        <!--Opacity="{Binding AnteSchedina.ScommessaStored, ConverterParameter=OVER, Converter={StaticResource OpacityConverter}, Source={StaticResource Locator}}">-->
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Tap">
                                            <Command:EventToCommand Command="{Binding AnteSchedina.UpdateScommessaCommand, Source={StaticResource Locator}}" 
                                                                    CommandParameterValue="OVER"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding Path=UNDER}" HorizontalAlignment="Center"/>
                                <Button Content="Under" 
                                        MinWidth="96"
                                        MinHeight="96" >
                                        <!--Opacity="{Binding AnteSchedina.ScommessaStored, ConverterParameter=UNDER, Converter={StaticResource OpacityConverter}, Source={StaticResource Locator}}">-->
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Tap">
                                            <Command:EventToCommand Command="{Binding AnteSchedina.UpdateScommessaCommand, Source={StaticResource Locator}}" 
                                                                    CommandParameterValue="UNDER"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>

                    <!-- Doppia Chance -->
                    <StackPanel Orientation="Vertical"
                                Visibility="{Binding DC1X, Converter={StaticResource StringToVisConverter}}"
                                Margin="12" >
                        <TextBlock Text="{Binding LocalizedResources.ScommessaDoppiaChanceTitle, Source={StaticResource LocalizedStrings}}" 
                                   HorizontalAlignment="Center" 
                                   FontSize="{StaticResource PhoneFontSizeMedium}" />
                        <StackPanel Orientation="Horizontal" 
                                    HorizontalAlignment="Center" >
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding DC1X}" HorizontalAlignment="Center" />
                                <Button Content="1X" 
                                        MinWidth="96"
                                        MinHeight="96" >
                                        <!--Opacity="{Binding AnteSchedina.ScommessaStored, ConverterParameter=DC1X, Converter={StaticResource OpacityConverter}, Source={StaticResource Locator}}">-->
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Tap">
                                            <Command:EventToCommand Command="{Binding AnteSchedina.UpdateScommessaCommand, Source={StaticResource Locator}}" 
                                                                    CommandParameterValue="DC1X"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding DC12}" HorizontalAlignment="Center" />
                                <Button Content="12" 
                                        MinWidth="96"
                                        MinHeight="96" >
                                        <!--Opacity="{Binding AnteSchedina.ScommessaStored, ConverterParameter=DC12, Converter={StaticResource OpacityConverter}, Source={StaticResource Locator}}">-->
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Tap">
                                            <Command:EventToCommand Command="{Binding AnteSchedina.UpdateScommessaCommand, Source={StaticResource Locator}}" 
                                                                    CommandParameterValue="DC12"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding DCX2}" HorizontalAlignment="Center" />
                                <Button Content="X2"
                                        MinWidth="96"
                                        MinHeight="96" >
                                        <!--Opacity="{Binding AnteSchedina.ScommessaStored, ConverterParameter=DCX2, Converter={StaticResource OpacityConverter}, Source={StaticResource Locator}}">-->
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Tap">
                                            <Command:EventToCommand Command="{Binding AnteSchedina.UpdateScommessaCommand, Source={StaticResource Locator}}" 
                                                                    CommandParameterValue="DCX2"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>

                    <!-- Home/Away -->
                    <StackPanel Orientation="Vertical"
                                Visibility="{Binding Home12, Converter={StaticResource StringToVisConverter}}"
                                Margin="12" >
                        <TextBlock Text="{Binding LocalizedResources.ScommessaHomeAwayTitle, Mode=OneWay, Source={StaticResource LocalizedStrings}}" 
                                   HorizontalAlignment="Center"
                                   FontSize="{StaticResource PhoneFontSizeMedium}" />
                        <StackPanel Orientation="Horizontal" 
                                    HorizontalAlignment="Center" >
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding Home12}" HorizontalAlignment="Center" />
                                <Button Content="1"
                                        MinWidth="96"
                                        MinHeight="96" >
                                        <!--Opacity="{Binding AnteSchedina.ScommessaStored, ConverterParameter=Home12, Converter={StaticResource OpacityConverter}, Source={StaticResource Locator}}">-->
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Tap">
                                            <Command:EventToCommand Command="{Binding AnteSchedina.UpdateScommessaCommand, Source={StaticResource Locator}}" 
                                                                    CommandParameterValue="Home12"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding Away12}" HorizontalAlignment="Center" />
                                <Button Content="2"
                                        MinWidth="96"
                                        MinHeight="96" >
                                        <!--Opacity="{Binding AnteSchedina.ScommessaStored, ConverterParameter=Away12, Converter={StaticResource OpacityConverter}, Source={StaticResource Locator}}">-->
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Tap">
                                            <Command:EventToCommand Command="{Binding AnteSchedina.UpdateScommessaCommand, Source={StaticResource Locator}}" 
                                                                    CommandParameterValue="Away12"/>
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
            </ScrollViewer>
        </Grid>
    </Grid>

</phone:PhoneApplicationPage>